﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows;

namespace for7raid.vk
{
    /* 
    <group>
  <gid>1</gid>
  <name>ВКонтакте API</name>
  <screen_name>apiclub</screen_name>
  <is_closed>0</is_closed>
  <is_admin>1</is_admin>
  <photo>http://cs400.vkontakte.ru/g00001/e_5ba03323.jpg</photo>
  <photo_medium>http://cs400.vkontakte.ru/g00001/d_7bfe2183.jpg</photo_medium>
  <photo_big>http://cs400.vkontakte.ru/g00001/a_9a5cd502.jpg</photo_big>
 </group>
     * */
    public class Group: DependencyObject
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string ScreenNname { get; set; }
        public string Photo { get; set; }
        public List<int> Users { get; set; }
            

        public static List<Group> FromResponse(XmlDocument doc)
        {
            return doc.SelectNodes("/response/group").OfType<XmlNode>().Select(i => new Group()
            {
                ID = i["gid"].ParseXmlNodeAsInt(),
                Name = i["name"].InnerText.Encode(),
                Photo= i["photo"].InnerText,
                ScreenNname=i["screen_name"].InnerText
            }).ToList();
        }

        public static bool FromResponseIsMember(XmlDocument doc)
        {
            return doc.SelectSingleNode("/response").InnerText == "1";
           
        }
    }
}
